package easy;

public class Solution_1678 {

    public String interpret(String command) {
        char[] chars = command.toCharArray();
        int index = 0;
        for (int i = 0; i < chars.length; i++) {
            if (chars[i]=='G') {
                chars[index++] = chars[i];
            } else if (chars[i]=='(' && chars[i+1]==')'){
                chars[index++] = 'o';
                i++;
            } else if (chars[i]=='(' && chars[i+1]=='a' && chars[i+2]=='l' && chars[i+3]==')') {
                chars[index++] = 'a';
                chars[index++] = 'l';
                i+=3;
            }
        }
        return new String(chars, 0, index);
    }

    /*public String interpret(String command) {
        return command.replace("()", "o").replace("(al)", "al");
    }*/

    public static void main(String[] args) {
        Solution_1678 model = new Solution_1678();
        System.out.println(model.interpret("G()(al)"));
        System.out.println(model.interpret("G()()()()(al)"));
        System.out.println(model.interpret("(al)G(al)()()G"));
    }
}
